//动态时钟
function myclock(){
    var time=new Date();
    var year=time.getFullYear();
    var month= time.getMonth()+1;
    var tian= time.getDate();
    var week= time.getDay();
    switch(week){
        case 1:week="一";break;
        case 2:week="二";break;
        case 3:week="三";break;
        case 4:week="四";break;
        case 5:week="五";break;
        case 6:week="六";break;
        case 7:week="日";break;
    }
    var hour= time.getHours()<10?"0"+time.getHours():time.getHours();
    var min= time.getMinutes()<10?"0"+time.getMinutes():time.getMinutes();
    var ss= time.getSeconds()<10?"0"+time.getSeconds():time.getSeconds();

    //var str=document.write(year+"年"+mouth+"月"+tian+"日星期"+week+hour+":"+min+":"+ss)
    //不能使用document.write,要把str赋给innerHTML,不能在使用输出语句,否则不显示
    var str=year+"年"+month+"月"+tian+"日&nbsp;&nbsp;星期"+week+"&nbsp;&nbsp;"+hour+":"+min+":"+ss;
    var objH1=document.getElementById("tm");
    objH1.innerHTML=str;
    setTimeout("myclock()",1000);
}
window.onload=myclock;

$(document).ready(function () {
    loginfo();
    function loginfo() {
        $.ajax({
            url:"user/loginfo",
            dataType:"json",
            type:"post",
            success:function (result) {
                console.info(result);
                var u_name = result.object.u_name;
                var r_name = result.object.r_name;
                $("#u_name").text(u_name);
                $("#r_name").text(r_name);
            }



        })

    }
    //树形菜单和面包屑导航
    // json文件url,data,返回的值
    // $.getJSON("json/menu_json.json",function(data){
    //     $("#mytreeview").treeview({
    //         data:data,
    //         collapseIcon:"",
    //         expandIcon:"",
    //         selectedBackColor:"#ddd",
    //         onNodeSelected:function(event,data){
    //             //面包屑导航要更新
    //             console.info(data);
    //             var parent=$("#mytreeview").treeview("getNode",data.parentId);
    //
    //             $("#breadcrumb").html('<li><a href="#">首页</a></li>\n' +
    //                 '<li><a href="#">'+parent.text+'</a></li>\n' +
    //                 '<li class="active"><a href="#">'+data.text+'</a></li>');
    //             $("#myiframe").attr("src",data.href);
    //
    //         }
    //
    //
    //     });
    // });

//select  option

    $("#queryDevice").on('shown.bs.select',function(e){
        $('#queryDevice').prev().find("input").keyup(function(){
            $('#queryDevice').prev().find("input").attr('id',"deviceInput"); //为input增加id属性
            console.log($('#deviceInput').val()); //获取输入框值输出到控制台
            var deviceInput = $('#deviceInput').val();
            var deviceStr="" ;
            for(var i=0; i<8; i++){
                deviceStr+="<option  data-icon='glyphicon glyphicon-heart' data-tokens='"+i+"'> 设备"+i+"</option>";
            }
            $("#queryDevice").html("");
            $('#queryDevice').append(deviceStr);
            $('#queryDevice').selectpicker('refresh');
        })

    });

    //登陆后手动清除登陆信息
    $("#clearLoginInfo").click(function () {
        localStorage.removeItem("u_name");
        localStorage.removeItem("u_pwd");
        alert("登陆信息已删除!")
    });


    //    面包屑
    // $("#bread_node1_1").click(function () {
    //     $("#breadcrumb").html("<li><a href='gotoroomIndex'>"+"首页"+"</a></li>"+
    //                           "<li class='active'> " + "房间管理"+ "</li>"+
    //                           "<li><a href='node/1_1' target='myiframe'>" + "房间信息管理" + "</a></li>");
    // });
    // $("#bread_node2_1").click(function () {
    //     $("#breadcrumb").html("<li><a href='gotoroomIndex'>"+"首页"+"</a></li>"+
    //                           "<li class='active'> " + "客户管理"+ "</li>"+
    //                           "<li><a href='node/2_1'target='myiframe'>" + "客户订单管理" + "</a></li>");
    // });
    // $("#bread_node3_1").click(function () {
    //     $("#breadcrumb").html("<li><a href='gotoroomIndex'>"+"首页"+"</a></li>"+
    //                           "<li class='active'> " + "人员管理"+ "</li>"+
    //                           "<li><a href='node/3_1' target='myiframe'>" + "人员信息管理" + "</a></li>");
    // });
    // $("#bread_node4_1").click(function () {
    //     $("#breadcrumb").html("<li><a href='gotoroomIndex'>"+"首页"+"</a></li>"+
    //                           "<li class='active'> " + "物资管理"+ "</li>"+
    //                           "<li><a href='node/4_1' target='myiframe'>" + "固定资产" + "</a></li>");
    // });
    // $("#bread_node4_2").click(function () {
    //     $("#breadcrumb").html("<li><a href='gotoroomIndex'>"+"首页"+"</a></li>"+
    //                           "<li class='active'> " + "物资管理"+ "</li>"+
    //                           "<li><a href='node/4_2' target='myiframe'> "+ "日常消耗" + "</a></li>");
    // });

});




















